package me.leon.mylibs;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.os.Environment;

import me.leon.devsuit.android.KeyboardUtils;
import me.leon.devsuit.android.LogUtils;
import me.leon.devsuit.android.Utils;
import me.leon.mylibs.DB.RealmManager;

/**
 * Author : Leon
 * E-mail : deadogone@gmail.com
 * Time   : 2017/11/27 0027 23:09
 * Desc   : This is Appp
 * Version: 1.0.1
 */

public class Appp extends Application implements Application.ActivityLifecycleCallbacks {
    @Override
    public void onCreate() {
        super.onCreate();
        Utils.init(Appp.this);

        LogUtils.Config config = LogUtils.getConfig();
        config.setLogSwitch(BuildConfig.DEBUG)
                .setDir(Environment.getExternalStorageDirectory().getAbsolutePath()+"/log/")
                .setGlobalTag("LeonDebug")
                .setLog2FileSwitch(true)
        ;

        RealmManager.getInstance().init(this,"Test",1);

        registerActivityLifecycleCallbacks(this);

    }


    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {

    }

    @Override
    public void onActivityStarted(Activity activity) {
        activity.findViewById(android.R.id.content).setOnClickListener(v-> KeyboardUtils.hideSoftInput(activity));

    }

    @Override
    public void onActivityResumed(Activity activity) {

    }

    @Override
    public void onActivityPaused(Activity activity) {

    }

    @Override
    public void onActivityStopped(Activity activity) {

    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

    }

    @Override
    public void onActivityDestroyed(Activity activity) {

    }
}
